<?php

class WP_Version_Implementation extends WP_Version_Writer
{
	private $info = array();

	public function __destruct()
	{
		
	}

	public function setup()
	{
		if( file_exists( WP_VERSION_STORAGE.'/save.txt' ) )
		{
			$save = file_get_contents(WP_VERSION_STORAGE.'/save.txt');
			$this->info = unserialize( $save );
		}
	}

	public function addType(WP_Version_Writer_Type $type)
	{
		if( !isset($this->info[ $type ]) ) {
			$this->info[ $type ] = array();
		}
	
		if( !isset($this->info[ $type ][ $name ]) ) {
			$this->info[ $type ][ $name ] = array();
		}
	
		if( false === in_array($this->version, $this->info[ $type ][ $name ]) ) {
			$this->info[ $type ][ $name ][] = $this->version;
		}
	}

	public function save()
	{
		file_put_contents( WP_VERSION_STORAGE.'/save.txt', serialize( $this->info ) );
	}

	public function dump()
	{
		var_dump($this->info);
	}

	public function getTypes()
	{
		return array_keys( $this->info );
	}

	public function getNames($type)
	{
		return array_keys( $this->info[ $type ] );
	}

	public function getVersions($type, $name)
	{
		return $this->info[ $type ][ $name ];
	}
}

